class Solution:
    def numberOfSubstrings(self, s: str) -> int:
        n = len(s)
        res = 0
        mapping = {}
        # try:
        mapping['a'] = s.index('a')
        mapping['b'] = s.index('b')
        mapping['c'] = s.index('c')
        for i, l in enumerate(s):
            res += n - max(mapping.values())
            print("res=",res)
            mapping[l] = s.index(l, i+1)
            print(mapping)
        # except ValueError:
            # print(mapping)
        return res
print(Solution().numberOfSubstrings("abcabc"))
